JavaScript Primer

  Contents

Useful JavaScript events for sonifying Web pages

JavaScript supports various events. These events enable you to script a response to a user's interaction with an HTML element on a Web page. The code that you write to respond to an event is termed an event handler. Event handlers can be used most effectively in making a user's interaction with a page trigger UI sounds or changes within an underlying musical score.

The events most commonly used in sonifying a Web page are outlined in the table below. Beatnik Inc. is not reponsible for the maintenance and extension of the JavaScript language and so you should view the table as merely a guide, and should always refer to Netscape's on-line JavaScript documentation as your primary JavaScript programming reference.

Event Handler Description HTML elements
ONCLICK Occurs when the user clicks a form element or link. ONCLICK is an action event and is very appropriate for use in UI sonification. Other events such as ONLOAD, ONCHANGE, ONBLUR, ONSELECT, etc., are less directly connected to immediate user actions. buttons
submit buttons
reset buttons
radio buttons
checkboxes
links
ONMOUSEOVER Occurs when the user moves the mouse pointer over a link. This is one of the more useful events to use in sonification as it allows one to sonify a user's movement over a Web page. Done in a tasteful manner, ONMOUSEOVER events can be used to script fun and engaging pages which give immediate gratification to the user. links
ONMOUSEOUT Occurs when the user moves the mouse pointer out of an area (client-side image map) or link. Paired with the ONMOUSEOVER event, you will find this event to be one of the most frequently used in scripting sonified Web pages. links
client-side image map areas
ONBLUR Occurs when the user removes input focus from a window, frame, or form element. windows
frames
all form elements
ONFOCUS Occurs when the user gives input focus to a window, frame, or form element. windows
frames
all form elements
ONLOAD Occurs when a page and associated media has finished loading. document body
ONUNLOAD Occurs when the user leaves a page. document body
ONABORT Occurs when the user aborts the loading of an image (for example by clicking a link or clicking the Stop button) images
ONERROR Occurs when the loading of a document or image causes an error. images
windows
ONSUBMIT Occurs when the user submits a form. submit button
ONRESET Occurs when the user resets a form (clicks a Reset button). forms
ONSELECT Occurs when the user selects a form element's input field. text fields
textareas
ONCHANGE Occurs when the user changes the value of an element. text fields
textareas
select lists

Refer also to Netscape's documentation on JavaScript's event support